package com.daguchuangyi.erp_android.model.product;

import android.os.Parcel;
import android.os.Parcelable;
import android.text.TextUtils;

import com.daguchuangyi.erp_android.manager.NetworkManager;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;

/**
 * Created by lijianjian on 2018/3/24.
 */

public class Photo implements Parcelable {
    @Expose
    @SerializedName("url")
    private String mImgUrl;

    public final static Creator<Photo> CREATOR = new Creator<Photo>() {

        @SuppressWarnings({
                "unchecked"
        })
        public Photo createFromParcel(Parcel in) {
            return new Photo(in);
        }

        public Photo[] newArray(int size) {
            return (new Photo[size]);
        }

    };

    protected Photo(Parcel in) {
        this.mImgUrl = ((String) in.readValue((int.class.getClassLoader())));
    }

    public Photo() {
    }

    public String getImgUrl() {
        if (TextUtils.isEmpty(mImgUrl)) {
            return mImgUrl;
        }
        return NetworkManager.getInstance().getBaseUrl() + mImgUrl;
    }

    public void setImgUrl(String imgUrl) {
        mImgUrl = imgUrl;
    }

    public void writeToParcel(Parcel dest, int flags) {
        dest.writeValue(mImgUrl);
    }

    public int describeContents() {
        return 0;
    }
}
